Skip to content

refactor: simplify index query, warn on MariaDB connections#1439

Merged
dimitri-yatsenko merged 2 commits intomasterfrom
fix/simplify-indexes-and-warn-mariadb
Apr 29, 2026
Merged

refactor: simplify index query, warn on MariaDB connections#1439
dimitri-yatsenko merged 2 commits intomasterfrom
fix/simplify-indexes-and-warn-mariadb

Conversation

@dimitri-yatsenko
Copy link
Copy Markdown
Member

@dimitri-yatsenko dimitri-yatsenko commented Apr 29, 2026

Summary

Follow-up to #1437. Two changes:

  1. Simplify get_indexes_sql(). Drop the EXPRESSION/fallback machinery: replace the COALESCE(COLUMN_NAME, CONCAT('(', EXPRESSION, ')')) primary query (and the get_indexes_sql_fallback() method, and the try/except wrapper in heading.py) with a single COLUMN_NAME-only query. Functional indexes (NULL COLUMN_NAME) are silently skipped downstream — the existing filter already handles them.
  2. Warn on MariaDB connections. Emit a UserWarning at connect time when the server reports MariaDB. DataJoint 2.x is officially MySQL/PostgreSQL only; MariaDB compatibility is best-effort and may break in future releases.

Also: pin CONTRIBUTING.md MySQL minimum to 8.0.13+ and reframe PostgreSQL as a peer production backend (not "an alternative").

Companion docs PR: datajoint/datajoint-docs#161

Trade-off

Functional-index detection by @schema is temporarily off the menu on all backends. No current consumer depends on it. When functional indexes are restored later, that PR can decide on the right MySQL version floor (and may turn the MariaDB warning into a hard error).

Test plan

  • New unit test tests/unit/test_connection_warning.py (8 cases: 3 MariaDB strings warn, 5 MySQL strings don't).
  • Full unit test suite passes (pixi run -e test pytest tests/unit/ — 257 passed).
  • ruff check and ruff format clean.
  • Manual smoke test against mariadb:10.11: @schema succeeds, warning fires, no Unknown column 'EXPRESSION'.
  • Manual smoke test against mysql:8.0: no warning fires.

Follow-up to #1437. Replace the EXPRESSION/fallback machinery with a
single COLUMN_NAME-only query — functional indexes (NULL COLUMN_NAME)
are silently skipped downstream. Functional-index detection is
temporarily off the menu; no current consumer depends on it.

Add a UserWarning at connect time when the server reports MariaDB.
DataJoint 2.x is officially MySQL/PostgreSQL only; MariaDB
compatibility is best-effort and may break in future releases.

Pin CONTRIBUTING.md MySQL minimum to 8.0.13+ and reframe PostgreSQL
as a peer production backend (not "an alternative").
test_describe round-trips Team().describe() through declare() and
asserts the SQL matches the original definition. Team has functional
indexes (json_value expressions), and Heading.indexes no longer
captures functional indexes (NULL COLUMN_NAME rows are skipped),
so describe() emits the table without them — the round-trip diverges.

Skip the test until functional-index introspection is restored.
@dimitri-yatsenko dimitri-yatsenko merged commit 4e4c788 into master Apr 29, 2026
7 checks passed
@dimitri-yatsenko dimitri-yatsenko deleted the fix/simplify-indexes-and-warn-mariadb branch April 29, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants